import random
import datetime

# 生成随机演示数据
def generate_demo_data(num_rows=20):
    # 定义数据类别和值范围
    departments = ['销售部', '市场部', '技术部', '人力资源部', '财务部', '客服部']
    statuses = ['活跃', '休假', '离职', '试用期']
    projects = ['项目A', '项目B', '项目C', '项目D', '项目E', '无']
    
    data = []
    
    print("生成的员工数据示例：")
    print("{:<8} {:<10} {:<12} {:<6} {:<10} {:<12} {:<10} {:<10} {:<10}".format(
        "员工ID", "姓名", "部门", "年龄", "薪资", "入职日期", "状态", "当前项目", "绩效评分"))
    print("="*90)
    
    for i in range(1, num_rows + 1):
        # 生成随机数据
        name = f'员工{i:03d}'
        department = random.choice(departments)
        age = random.randint(22, 60)
        salary = round(random.uniform(5000, 25000), 2)
        hire_date = (datetime.datetime.now() - datetime.timedelta(days=random.randint(30, 3650))).strftime('%Y-%m-%d')
        status = random.choice(statuses)
        project = random.choice(projects)
        performance = random.randint(60, 100)
        
        # 添加到数据列表
        data.append({
            'id': i,
            'name': name,
            'department': department,
            'age': age,
            'salary': salary,
            'hire_date': hire_date,
            'status': status,
            'project': project,
            'performance': performance
        })
        
        # 打印数据行
        print("{:<8} {:<10} {:<12} {:<6} {:<10} {:<12} {:<10} {:<10} {:<10}".format(
            i, name, department, age, f"¥{salary}", hire_date, status, project, performance))
    
    print(f"\n总共生成了 {len(data)} 条员工数据。")
    return data

# 主函数
if __name__ == "__main__":
    # 生成20条演示数据
    data = generate_demo_data(20)